Using the Eclipse C/C++ Development Tooling as a Robust, Fully Functional, Actively Maintained, Open Source C++ Parser

نویسندگان

  • Danila Piatov
  • Andrea Janes
  • Alberto Sillitti
  • Giancarlo Succi
چکیده

Open Source parsers that support contemporary C/C++, can recover from errors, include a preprocessor, and that are actively maintained, are rare. This work describes how to use the parser contained in the Eclipse C/C++ Development Tooling (CDT) as a Java library. Such parser provides not only the abstract syntax tree of the parsed le but also the semantics, i.e., type information and bindings. The authors used the same approach to obtain Java and JavaScript parsers. Programming language parsers are used by industry and research to create compilers or interpreters, statical code analysis tools, code metrics tools, source code editors with code completion, etc. Parsing C/C++ is particularly tricky (e.g., a construct a * b can be a multiplication or a pointer de nition depending on the type of a). Generic Open Source parser generators do not alleviate this task since the ambiguities cannot be resolved by a parser alone but require type information. We searched for Open Source C++ parsers that include a preprocessor, perform semantic analysis (resolve type information and name bindings), are robust, and support contemporary C/C++ features. Of the found parsers, namely cpp-ripper, Elsa, GCC using the -fdump-translation-unit option, GCC_XML, Clang, and the Eclipse CDT parser only the latter 2 ful lled the requirements. We decided to opt for the Eclipse parser since the approach could also (and did) provide us with parsers for other languages like Java and JavaScript. The actual parser is located in the le org.eclipse.cdt.core_X.jar , in the Eclipse installation folder, where X stands for version of the le. The jar itself is an Eclipse plugin, however, it is possible to use it as a Java library, without initializing the Eclipse platform. The instruction org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage. getDefault().getASTTranslationUnit(FileContent, IScannerInfo, IncludeFileContentProvider, IIndex, int, IParserLogService) performs the actual parsing, returning an abstract syntax tree (AST). This work deals with an (apparently) simple problem: to nd a working C++ parser . Eclipse CDT contains such parser, but there is no o cial documentation about using it as a library outside of Eclipse. We hope that our poster can ll this gap and be of help.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Domain-Specific Language Integration with C++ Template Metaprogramming

Domain specific language integration has to provide the right balance between the expressive power of the DSL and the implementation and maintenance cost of the applied integration techniques. External solutions may perform poorly as they depend on third party tools which should be implemented, tested and then maintained during the whole lifetime of the project. Ideally a self-contained solutio...

متن کامل

Re-engineering Eclipse MDT/OCL for Xtext

The current tooling used for the Eclipse OCL project uses an LALR parser generator. Enhancing the tooling to support editing motivated a migration to exploit the inherently model-driven characteristics of Xtext. This paper summarizes the experiences of that migration, identifies the many benefits and discusses a few changes in implementation approach that were required. Objective performance an...

متن کامل

Implementing Monads for C + + Template Metaprograms ∗ Technical report TR -

C++ template metaprogramming is used in various application areas, such as expression templates, static interface checking, active libraries, etc. Its recognized similarities to pure functional programming languages – like Haskell – make the adoption of advanced functional techniques possible. Such a technique is using monads, programming structures representing computations. Using them actions...

متن کامل

Performance and Creativity Indicators within Communication Patterns of the Open Source Community

Introduction This research brief reports on the communication patterns of online communities of developers and users of the open source Eclipse Java development environment. The research involved measuring the productivity of each community and identifying correlations that exist between group communication characteristic and productivity attributes. The TeCFlow (Temporal Communication Flow) vi...

متن کامل

Adaptive Observer-Based Decentralized Scheme for Robust Nonlinear Power Flow Control Using HPFC

This paper investigates the robust decentralized nonlinear control of power flow in a power system using a new configuration of UPFC. This structure comprises two shunt converters and one series capacitor called as hybrid power flow controller (HPFC). A controller is designed via control Lyapunov function (CLF) and adaptive observer to surmount the problems of stability such as tracking desired...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2012